package com.fsnbigdata.domain;
import org.hibernate.annotations.Index;
import org.hibernate.validator.constraints.Length;
import org.springframework.roo.addon.javabean.annotations.RooEquals;
import org.springframework.roo.addon.javabean.annotations.RooJavaBean;
import org.springframework.roo.addon.javabean.annotations.RooToString;
import org.springframework.roo.addon.jpa.annotations.entity.RooJpaEntity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
import io.springlets.format.EntityFormat;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import java.util.Objects;
import javax.persistence.Entity;

/**
 * = Distribution
 *
 * TODO Auto-generated class documentation
 *
 */
@RooJavaBean
@RooToString
@RooJpaEntity
@RooEquals(isJpaEntity = true)
@Entity
@EntityFormat
public class Distribution {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Version
    private Integer version;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @EntityFormat
    private Organism organism;

    /**
     * 是否标准地址
     */
    private Boolean standard;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Length(min = 0, max = 255,message ="国家信息内容长度必须在0-255个字符之间")
    private String country;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Length(min = 0, max = 255,message ="省信息内容长度必须在0-255个字符之间")
    @Index(name="distribution_province")
    private String province;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Length(min = 0, max = 255,message ="城市信息内容长度必须在0-255个字符之间")
    @Index(name = "dis_city")
    private String city;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Length(min = 0, max = 255,message ="区、县信息内容长度必须在0-255个字符之间")
    @Index(name = "dis_county")
    private String county;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Length(min = 0, max = 200,message ="小地区内容长度必须在0-200个字符之间")
    private String detail;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * This `equals` implementation is specific for JPA entities and uses
     * the entity identifier for it, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @param obj
     * @return Boolean
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        // instanceof is false if the instance is null
        if (!(obj instanceof Distribution)) {
            return false;
        }
        return getId() != null && Objects.equals(getId(), ((Distribution) obj).getId());
    }

    /**
     * This `hashCode` implementation is specific for JPA entities and uses a fixed `int` value to be able
     * to identify the entity in collections after a new id is assigned to the entity, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @return Integer
     */
    @Override
    public int hashCode() {
        return 31;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Long
     */
    public Long getId() {
        return this.id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Integer
     */
    public Integer getVersion() {
        return this.version;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param version
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Organism
     */
    public Organism getOrganism() {
        return this.organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param organism
     */
    public void setOrganism(Organism organism) {
        this.organism = organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Boolean
     */
    public Boolean getStandard() {
        return this.standard;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param standard
     */
    public void setStandard(Boolean standard) {
        this.standard = standard;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCountry() {
        return this.country;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param country
     */
    public void setCountry(String country) {
        this.country = country;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getProvince() {
        return this.province;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param province
     */
    public void setProvince(String province) {
        this.province = province;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCity() {
        return this.city;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param city
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCounty() {
        return this.county;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param county
     */
    public void setCounty(String county) {
        this.county = county;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getDetail() {
        return this.detail;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param detail
     */
    public void setDetail(String detail) {
        this.detail = detail;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String toString() {
        return "Distribution {" + "id='" + id + '\'' + ", version='" + version + '\'' + ", standard='" + standard + '\'' + ", country='" + country + '\'' + ", province='" + province + '\'' + ", city='" + city + '\'' + ", county='" + county + '\'' + ", detail='" + detail + '\'' + ", ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE + '\'' + ", ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE + '\'' + "}" + super.toString();
    }
}
